﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using QLT_BLL;
using QLT_Public;


namespace GiaoDien
{
    public partial class uc_TKKhachHang : DevExpress.XtraEditors.XtraUserControl
    {
        public uc_TKKhachHang()
        {
            InitializeComponent();
        }
        KhachHang_BLL khachhang_bll = new KhachHang_BLL();
        private void btnTimKiem_Click(object sender, EventArgs e)
        {
            KhachHang_Public k = new KhachHang_Public();
            if (txtTenKH.Text != "")
            {
                k.TenKH = txtTenKH.Text;
                gridControl1.DataSource = khachhang_bll.TimKiem_TenKH(k);
            }
            if (txtDiaChi.Text != "")
            {
                k.DiaChi = txtDiaChi.Text;
                gridControl1.DataSource = khachhang_bll.TimKiem_DiaChi(k);
            }
            if (txtTenKH.Text != "" && txtDiaChi.Text != "")
            {
                k.TenKH = txtTenKH.Text;
                k.DiaChi = txtDiaChi.Text;
                gridControl1.DataSource = khachhang_bll.TimKiem_TenKH_DiaChi(k, k);
            }
        }

        private void uc_TKKhachHang_Load(object sender, EventArgs e)
        {
            gridControl1.DataSource = khachhang_bll.Load_TimKiem_KhachHang();
        }
        public void Huy_Text(Control ctr)
        {
            if (ctr is TextBox || ctr is TextEdit)
            {
                ctr.Text = string.Empty;
            }
            foreach (Control i in ctr.Controls)
            {
                Huy_Text(i);
            }
        }

        private void btnLamMoi_Click(object sender, EventArgs e)
        {
            Huy_Text(this);
            uc_TKKhachHang_Load(sender, e);
        }
    }
}
